package com.cqeec.waimai.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
//告诉spring  这是一个配置类
@Configuration
//mapper扫描，防止找不到mapper文件
@MapperScan("com.cqeec.waimai.mapper")
public class MpConfig {
//    创建分页拦截器
    @Bean
    public MybatisPlusInterceptor interceptor() {
//        实例化分页拦截器
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
//        添加分页拦截器，这里以mysql为例
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return interceptor;
    }
}
